Create Your First Functional Component in React JS – Beginner's Guide

Image
Create Your First Functional Component in React JS  1. Introduction When you start learning React JS, one of the first things you will come across is the concept of components. At first, components may seem like just another programming concept, but they are actually the foundation of almost every React application. Think about a website you use every day. It may have a header, navigation menu, login form, product section, and footer. Instead of writing all these elements together in one large file, React allows us to create separate parts and manage them independently. These separate parts are called components. In this tutorial, we are going to create our first functional component in React. We will start with a very simple example and gradually understand how components are created, exported, imported, and displayed on a webpage.  2. What Is a Functional Component in React?   A functional component is simply a JavaScript function that returns a user interface using JSX...

Write C Program to Print Inverted Half Pyramid of Stars Pattern

 

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Example 


#include<stdio.h>


void main ()

{

int i,j,r;


printf("enter the number");

scanf("%d",&r);

for(i=r;i>=1;i--)

{


for(j=1;j<=i;j++)

{

printf("*");

}

printf("\n");

}

return 0;

}


Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Explain Program

Step :1

#include <stdio.h>

  • standard input-output library, printf() and scanf() function

Step :2

void main()

  • starting point of the program.

Step :3

. int i, j, r;

  • Declares three integer variables:
  • r: the number of rows (input from the user).
  • i: used for the outer loop (rows).
  • j: used for the inner loop (columns/asterisks per row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows for the triangle.

Step :5

for(i = r; i >= 1; i--)

  • Starts at i = r and decrements to 1.
  • First row has r stars,
  • Second row has r-1 stars,

Step :6

for(j = 1; j <= i; j++)

{

    printf("*");

}

  • row, prints i number of asterisks (*).
The number of asterisks decreases as i decreases

Step :7

printf("\n");

  •  cursor to the next line after each row of asterisks.

Step :8

return 0;

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern
 Program Output :- 

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern


Related Post :-


Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples